<%@ page language="java" pageEncoding="UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<%@ include file="../../common/common.jsp" %>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>${menu_name } - ${title }</title>
</head>
<link href="${ctx }/static/plugins/chosen_v1.6.2/chosen.css" rel="stylesheet"/>
<body
        <%@ include file="../../common/skin.jsp" %>
>
<%@ include file="../../common/head.jsp" %>
<%@ include file="../../common/menu.jsp" %>
<div class="J_content">
    <div class="mt20 plr20">
        <form action="${ctx }/channel/activityAlerts/list" id="queryForm" method="post">
            <input type="hidden" name="state" value="${state}">
            <div class="J_toolsBar clearfix">
                <select name="type" class="t_text ml10" style="border-radius: 6px">
                    <option value="-1" selected>-模块-</option>
                    <c:choose>
                        <c:when test="${state == '0'}">
                            <option value="0" <c:if test="${dto.type == '0'}">selected</c:if>>
                                协会快讯
                            </option>
                            <option value="1" <c:if test="${dto.type == '1'}">selected</c:if>>
                                重要活动
                            </option>
                            <option value="2" <c:if test="${dto.type == '2'}">selected</c:if>>
                                年度计划
                            </option>
                        </c:when>
                        <c:otherwise>
                            <option value="0" <c:if test="${dto.type == '0'}">selected</c:if>>
                                会员名录
                            </option>
                            <option value="1" <c:if test="${dto.type == '1'}">selected</c:if>>
                                会员动态
                            </option>
                            <option value="2" <c:if test="${dto.type == '2'}">selected</c:if>>
                                会员服务
                            </option>
                        </c:otherwise>
                    </c:choose>
                </select>
                <select name="deleteFlag" class="t_text ml10" style="border-radius: 6px">
                    <option value="-1" selected>-状态-</option>
                    <option value="0" <c:if test="${dto.deleteFlag == '0'}">selected</c:if>>
                        正常
                    </option>
                    <option value="1" <c:if test="${dto.deleteFlag == '1'}">selected</c:if>>
                        删除
                    </option>
                </select>
                <div class="t_button mgl30">
                    <a class="abtn red" href="javascript:myQuery();">
                        <i class="icon"></i>查询
                    </a>
                </div>
                <div class="t_button ml10">
                    <a class="abtn blue" href="javascript:myEdit();">
                        <i class="icon"></i>新增
                    </a>
                </div>
                <div class="t_label ml10">
                    记录数：<label style="color: red;" id="total">${page.totalCount }</label>
                </div>
            </div>

            <div class="J_table mt20">
                <div class="t_table">
                    <table>
                        <thead>
                        <tr>
                            <td>
                                <span>序号</span>
                            </td>
                            <td>
                                <span>标题</span>
                            </td>
                            <td>
                                <span>作者</span>
                            </td>
                            <td>
                                <span>来源</span>
                            </td>
                            <td>
                                <span>图片</span>
                            </td>
                            <td>
                                <span>导读</span>
                            </td>
                            <td>
                                <span>模块</span>
                            </td>
                            <td>
                                <span>状态</span>
                            </td>
                            <td>
                                <span>操作</span>
                            </td>
                        </tr>
                        </thead>
                        <tbody>
                        <c:choose>
                            <c:when test="${page.list != null && page.totalCount > 0 }">
                                <c:forEach items="${page.list }" var="u" varStatus="status">
                                    <tr>
                                        <td>
                                            <div class="t_text tc">
                                                    ${status.index+1 }
                                            </div>
                                        </td>
                                        <td>
                                            <div class="t_text tc">
                                                <c:if test="${fn:length(u.title)<=17}">
                                                    ${u.title}
                                                </c:if>
                                                <c:if test="${fn:length(u.title)>17}">
                                                    ${fn:substring(u.title,0,17)}...
                                                </c:if>
                                            </div>
                                        </td>
                                        <td>
                                            <div class="t_text tc">
                                                    ${u.author }
                                            </div>
                                        </td>
                                        <td>
                                            <div class="t_text tc">
                                                    ${u.source }
                                            </div>
                                        </td>
                                        <td>
                                            <div class="t_text tc">
                                                <c:choose>
                                                    <c:when test="${u.url != null && u.url != ''}">
                                                        <img src="${ctx }${u.url}" id="attachURL" width="100px"
                                                             height="100px"/>
                                                    </c:when>
                                                    <c:otherwise>
                                                        <img src="${ctx }/static/images/J_null.png" id="attachURL"
                                                             width="100px" height="100px"/>
                                                    </c:otherwise>
                                                </c:choose>
                                            </div>
                                        </td>

                                        <td>
                                            <div class="t_text tc">
                                                <c:if test="${fn:length(u.introduction)<=17}">
                                                    ${u.introduction}
                                                </c:if>
                                                <c:if test="${fn:length(u.introduction)>17}">
                                                    ${fn:substring(u.introduction,0,17)}...
                                                </c:if>
                                            </div>
                                        </td>
                                        <td>
                                            <div class="t_text tc">
                                                <c:choose>
                                                    <c:when test="${state == '0'}">
                                                        ${u.type == '0' ? "协会快讯" : u.type == '1' ? "重要活动" : "年度计划"}
                                                    </c:when>
                                                    <c:otherwise>
                                                        ${u.type == '0' ? "会员名录" : u.type == '1' ? "会员动态" : "会员服务"}
                                                    </c:otherwise>
                                                </c:choose>
                                            </div>
                                        </td>

                                        <td>
                                            <div class="t_text tc">
                                                <c:choose>
                                                    <c:when test="${u.deleteFlag == 0}">
                                                        正常
                                                    </c:when>
                                                    <c:otherwise>
                                                        <label class="delete_flag">删除</label>
                                                    </c:otherwise>
                                                </c:choose>
                                            </div>
                                        </td>
                                        <td>
                                            <div class="t_link">
                                                <a href="javascript:stick('${u.id }');">↑置顶</a>
                                                <a href="javascript:myEdit('${u.id }');"><i class="icon"></i>编辑</a>
                                                <c:choose>
                                                    <c:when test="${u.deleteFlag == 0}">
                                                        <a href="javascript:updStatus('${u.id }');"><i
                                                                class="icon"></i>删除</a>
                                                    </c:when>
                                                    <c:otherwise>
                                                        <a href="javascript:updStatus('${u.id }');"><i
                                                                class="icon"></i>恢复</a>
                                                    </c:otherwise>
                                                </c:choose>
                                            </div>
                                        </td>
                                    </tr>

                                </c:forEach>
                            </c:when>
                            <c:otherwise>
                                <tr>
                                    <td colspan="8">
                                        <div class="J_null mt40">
                                            <img src="${ctx }/static/images/null.png">
                                            <p>暂无相关数据</p>
                                        </div>
                                    </td>
                                </tr>
                            </c:otherwise>
                        </c:choose>
                        </tbody>
                    </table>
                </div>
                <%@ include file="../../common/pager.jsp" %>
            </div>
        </form>
    </div>
</div>
<script src="${ctx }/static/plugins/chosen_v1.6.2/chosen.jquery.js"></script>
<script type="text/javascript">
    function myEdit(id) {
        var state = ${state};
        window.location.href = '${ctx}/channel/activityAlerts/edit?id=' + id + '&state=' + state;
    }
    function stick(id) {
        $.ajax({
            url: '${ctx}/channel/activityAlerts/stick',
            type: 'post',
            data: {
                'id': id
            },
            traditional: true,
            success: function (result) {
                window.location.reload();
            }
        });
    }
    function mySubmit() {
        $('#editForm').submit();
    }

    function myQuery() {
        $('#queryForm').submit();
    }

    function updStatus(id) {
        var content = '确定到执行操作吗?';
        layer.confirm(content, function (index) {
            layer.close(index);
            var loadIdx = layer.load();
            $.ajax({
                url: '${ctx}/channel/activityAlerts/del',
                type: 'post',
                data: {
                    'id': id,
                },
                traditional: true,
                success: function (result) {
                    layer.close(loadIdx);
                    if (result.success) {
                        layer.alert('操作成功', function () {
                            window.location.reload();
                        });
                    } else {
                        layer.alert('操作失败');
                    }
                }
            });
        });
    }
</script>
</body>
</html>